package com.mrwu.test;

import com.mrwu.Dao;
import com.mrwu.Daoimpl;
import com.mrwu.aspect.Myaspect;
import org.junit.Test;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @Authther: mrwu
 * @date:2021/3/18-03
 * @Description:com.mrwu.test
 */
public class Demo {

    @Test
    public void test(){
        Dao o =(Dao) Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[]{Dao.class}, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                new Myaspect().check();
                return method.invoke(new Daoimpl(), args);
            }
        });

        o.save();

    }

    public static void main(String[] args) {
//        new Daoimpl()

    }

}
